﻿#include "mainwindow.h"
#include "ui_mainwindow.h"
#include <QtGui>
int firstIndex=0;

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);


    //ui->toolbox->setHeaderHidden(true);
    //ui->treeWidget->setHeaderLabel(tr("gg"));
    frm1=new Form1(this);
    frm2=new Form2(this);
    zhujiemian1=new zhujiemian(this);
    shujujieshou1=new shujujieshou(this);
    renmianruanjian1=new renmianruanjian(this);

    ui->stackedWidget->addWidget(frm1);
    ui->stackedWidget->addWidget(frm2);
    ui->stackedWidget->addWidget(zhujiemian1);
    ui->stackedWidget->addWidget(shujujieshou1);
    ui->stackedWidget->addWidget(renmianruanjian1);
    ui->stackedWidget->setCurrentWidget(zhujiemian1);
   //ui->stackedWidget->setCurrentWidget(frm2);//主界面右侧窗口显示界面
    firstIndex=ui->stackedWidget->currentIndex();

    //connect(ui->qtreewidgetitem7, SIGNAL(clicked()), this, SLOT(WinChoose()));
    //connect(ui.treeWidget, SIGNAL(clicked()), this, SLOT(ChooseWidgets()));
    //这个函数执行功能：选中树状列表某一项，调转至相应的界面

//    delete frm1;
//    delete frm2;
//    delete zhujiemian1;
//    delete shujujieshou1;
//    delete renmianruanjian1;

}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::WinChange()
{
    //获取页面的数量
       int nCount = ui->stackedWidget->count();
       //获取当前页面的索引
       int nIndex = ui->stackedWidget->currentIndex();
       //获取下一个需要显示的页面索引
       nIndex++;

       //当需要显示的页面索引大于等于总页面时，切换至首页
       if (nIndex >= nCount)
       {
           nIndex = firstIndex;
       }

       //显示当前页面
       ui->stackedWidget->setCurrentIndex(nIndex);
}



void MainWindow::on_pushButton_20_clicked()
{
    ui->pushButton_21->setDown(false);
    ui->pushButton_22->setDown(false);
    ui->pushButton_20->setDown(true);

    ui->stackedWidget->setCurrentWidget(frm1);
}

void MainWindow::on_pushButton_21_clicked()
{
    ui->pushButton_20->setDown(false);
    ui->pushButton_22->setDown(false);
    ui->pushButton_21->setDown(true);
    ui->stackedWidget->setCurrentWidget(shujujieshou1);
}

void MainWindow::on_pushButton_22_clicked()
{
    ui->pushButton_21->setDown(false);
    ui->pushButton_20->setDown(false);
    ui->pushButton_22->setDown(true);
//    ui->pushButton_22->setStyleSheet("background-color:rgb(120,200,200);");
    ui->stackedWidget->setCurrentWidget(renmianruanjian1);
}
